﻿using System;
using System.Collections.Generic;
using System.Data.Services;
using System.Data.Services.Common;
using System.Linq;
using System.ServiceModel.Web;
using System.Web;
using Autorent.DAL;
using System.IO;

namespace Autorent.Service
{
    public class AutorentMngrService : SecureAutoRentDataService
    {
        protected override bool AllowAnonymousAccess { get { return true; } }
        protected override string SystemUserRole { get { return "Manager"; } }

        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            string[] entities = new string[] {
                "Autoes", "AutoClasses", "AutoOrders", "Cities", "Clients", "ClientAddresses",
                "Countries", "Employees", "EmployeeAddresses", "Offices", "Payments", "Regions",
                "Streets", "SystemUsers"
            };
            entities.ToList().ForEach(x => config.SetEntitySetAccessRule(x, EntitySetRights.All));
            
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
        }
    }
}
